package com.zmn.oms.api.listener;

import com.alibaba.fastjson.JSON;
import com.zmn.manager.mq.annotation.AliyunMQHandler;
import com.zmn.manager.mq.annotation.AliyunMQListener;
import com.zmn.oms.manager.utils.OmsMqTagConsts;
import com.zmn.oms.model.dto.order.OrderOperationFailMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 类描述：工单操作失败监听器
 *
 * @author lhl
 * @date 2020/01/10 18:20
 */
@Slf4j
@AliyunMQListener(topic = "${spring.mq.topic.oms}")
@Component
public class OrderOperationFailListener {

    /**
     * 收到订单操作失败消息
     *
     * @param message
     */
    @AliyunMQHandler(tags = OmsMqTagConsts.ZMN_TOPIC_OMS_ORDER_OPERATION_FAIL_SYNC_API)
    public void onMessage(String message) {
        try {
            log.info("#mq#order#operationFail#recive message:{}", message);
            OrderOperationFailMessage failMessage = JSON.parseObject(message, OrderOperationFailMessage.class);

            Integer channelId = failMessage.getChannelId();

            // TODO -lhl 订单操作失败，会在这里监控到
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
}
